<template>
  <div class="page">
    <form class="layui-form" action="javascript:void(0)" lay-filter="component-form-group" v-if="seadate.length > 0">
      <div class="layui-form-item">
        <div class="layui-inline" v-for="(item, index) in seadate" :key="index">
          <label class="layui-form-label">{{ item.title }}</label>
          <div class="layui-input-block" v-if="item.type == 'input'">
            <input type="text" :name="item.field" :id="item.id" :placeholder="'请输入' + item.title" autocomplete="off"
              class="layui-input searchval" />
          </div>
          <div class="layui-input-block" v-else-if="item.type == 'select'">
            <select :name="item.field" class="searchval">
              <option v-for="(it, index1) in item.option" :value="it.val" :key="index1">{{ it.name }}</option>
            </select>
          </div>
        </div>
        <div class="layui-inline">
          <button class="layui-btn layuiadmin-btn-useradmin  layui-btn-normal" @click="search">
            <i class="layui-icon layui-icon-search layuiadmin-button-btn"></i>
          </button>
        </div>
      </div>
    </form>
  </div>
</template>
<script>
export default {
  name: "Search",
  props: {
    seadate: ""
  },
  data () {
    return {};
  },
  mounted () { },
  methods: {
    search: function () {
      var cons = [];
      $(".searchval").each(function () {
        var obj = {};
        obj.key = $(this).attr("name");
        obj.val = $(this).val();
        cons.push(obj);
        // console.log(obj);
      });
      // alert(JSON.stringify(cons))
      this.$parent.sousuo(cons);
    }
  }
};
</script>
<style scoped></style>
